<template>
  <div
    class="smallCard-box"
    :style="
      'min-width:' +
      width +
      (border ? ';padding-left:15px;border-left: 2px solid #EFF4FB' : ';')
    "
  >
    <div class="smallCard-title">{{ title }}</div>
    <div class="small-botton">
      <div class="smallCard-icon" :style="'background:' + color">
        <img :src="icon" alt="" />
      </div>
      <div class="text-box">
        <div class="smallCard-num">
          <countTo
            :startVal="num"
            :endVal="num"
            :duration="1000"
            :decimals="decimals ? 2 : 0"
          ></countTo>
        </div>
        <div class="smallCard-unit">{{ unit }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import countTo from "vue-count-to";
export default {
  props: {
    title: {
      type: String,
    },
    icon: {
      type: String,
    },
    num: {
      type: Number,
    },
    unit: {
      type: String,
    },
    color: {
      type: String,
    },
    width: {
      type: String,
    },
    border: {
      type: Boolean,
      default: true,
    },
    decimals: {
      type: Boolean,
      default: false,
    },
  },
  components: {
    countTo,
  },
};
</script>

<style lang="less" scoped>
.smallCard-box {
  height: 100%;
  display: inline-block;
  vertical-align: top;
  div {
    display: inline-block;
  }
  .smallCard-title {
    display: block;
    font-size: 18px;
    font-family: "Source Han Sans CN";
    font-weight: 900;
    color: #333333;
    padding-bottom: 25px;
  }
  .smallCard-icon {
    background: #12c47b;
    border-radius: 50%;
    padding: 12px;
    width: 54px;
    height: 54px;
    text-align: center;
    position: relative;
    vertical-align: middle;
    img {
      height: 30px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }
  .small-botton {
    white-space: nowrap;
  }
  .text-box {
    vertical-align: middle;
  }
  .smallCard-num {
    padding-left: 15px;
    font-size: 24px;
    font-family: "TsangerYuYangT";
    font-weight: 400;
    color: #3f3f3f;
    vertical-align: bottom;
    line-height: 30px;
    position: relative;
    top: 50%;
  }
  .smallCard-unit {
    font-size: 14px;
    font-family: "Source Han Sans CN";
    font-weight: 400;
    color: #333333;
    line-height: 24px;
    vertical-align: bottom;
    padding: 0 20px 0 5px;
  }
}
</style>
